package com.Blog.www.dao.Impl;

import com.Blog.www.dao.FriendDao;
import com.Blog.www.utils.SqlDao;

/**
 * 关注类
 *
 * @author 君未洋
 */
public class FriendDaoImpl implements FriendDao {

    private static SqlDao dao = new SqlDao();

    @Override
    public Integer findFriend(int aid, int uid) {
        //调用dao方法查询
        String sql = "select count(*) as count from friend where author_id = ? and user_id = ?";
        return dao.selectCount(sql, aid, uid);
    }

    @Override
    public boolean delete(Integer aid, Integer id) {
        String sql = "delete from friend where author_id = ? and user_id = ?";
        return dao.update(sql, aid, id);
    }

    @Override
    public boolean add(Integer aid, Integer id) {
        String sql = "insert into friend values (null,?,?)";
        return dao.update(sql, aid, id);
    }

    @Override
    public Integer getCount(Integer aid) {
        String sql = "select count(*) as count from friend where author_id = ?";
        return dao.selectCount(sql, aid);
    }
}
